package o;

import android.util.Pair;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.audio.Ac3Util;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.extractor.mp4.MdtaMetadataEntry;
import com.google.android.exoplayer2.extractor.mp4.Track;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.Metadata.Entry;
import com.huawei.appgallery.festivalanimation.particle.modifiers.SizeModifier;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public final class aez {
    private static final int ʻ = anr.ᐝ("meta");
    private static final int ʽ = anr.ᐝ("mdta");
    private static final int ˊ = anr.ᐝ("soun");
    private static final int ˋ = anr.ᐝ("text");
    private static final int ˎ = anr.ᐝ("vide");
    private static final int ˏ = anr.ᐝ("sbtl");
    private static final int ॱ = anr.ᐝ("subt");
    private static final int ॱॱ = anr.ᐝ("clcp");
    private static final byte[] ᐝ = anr.ˊ("OpusHead");

    interface d {
        int ˋ();

        boolean ˏ();

        int ॱ();
    }

    static final class a implements d {
        private final anc ˊ;
        private final int ˋ = this.ˊ.ʽॱ();
        private int ˎ;
        private final int ˏ = (this.ˊ.ʽॱ() & 255);
        private int ॱ;

        public a(o.aeu.d dVar) {
            this.ˊ = dVar.ॱᐨ;
            this.ˊ.ˋ(12);
        }

        public int ॱ() {
            return this.ˋ;
        }

        public int ˋ() {
            if (this.ˏ == 8) {
                return this.ˊ.ʽ();
            }
            if (this.ˏ == 16) {
                return this.ˊ.ॱॱ();
            }
            int i = this.ॱ;
            this.ॱ = i + 1;
            if (i % 2 != 0) {
                return this.ˎ & 15;
            }
            this.ˎ = this.ˊ.ʽ();
            return (this.ˎ & 240) >> 4;
        }

        public boolean ˏ() {
            return false;
        }
    }

    static final class b {
        public Format ˊ;
        public final afe[] ˋ;
        public int ˎ = 0;
        public int ˏ;

        public b(int i) {
            this.ˋ = new afe[i];
        }
    }

    static final class c {
        private int ʻ;
        private final anc ʼ;
        public final int ˊ;
        private final boolean ˋ;
        public int ˎ;
        public long ˏ;
        public int ॱ;
        private int ॱॱ;
        private final anc ᐝ;

        public c(anc o_anc, anc o_anc2, boolean z) {
            boolean z2 = true;
            this.ʼ = o_anc;
            this.ᐝ = o_anc2;
            this.ˋ = z;
            o_anc2.ˋ(12);
            this.ˊ = o_anc2.ʽॱ();
            o_anc.ˋ(12);
            this.ॱॱ = o_anc.ʽॱ();
            if (o_anc.ॱᐝ() != 1) {
                z2 = false;
            }
            amm.ˏ(z2, "first_chunk must be 1");
            this.ˎ = -1;
        }

        public boolean ˏ() {
            int i = this.ˎ + 1;
            this.ˎ = i;
            if (i == this.ˊ) {
                return false;
            }
            long ʼॱ;
            if (this.ˋ) {
                ʼॱ = this.ᐝ.ʼॱ();
            } else {
                ʼॱ = this.ᐝ.ˋॱ();
            }
            this.ˏ = ʼॱ;
            if (this.ˎ == this.ʻ) {
                this.ॱ = this.ʼ.ʽॱ();
                this.ʼ.ˎ(4);
                i = this.ॱॱ - 1;
                this.ॱॱ = i;
                this.ʻ = i > 0 ? this.ʼ.ʽॱ() - 1 : -1;
            }
            return true;
        }
    }

    static final class e implements d {
        private final int ˎ = this.ˏ.ʽॱ();
        private final anc ˏ;
        private final int ॱ = this.ˏ.ʽॱ();

        public e(o.aeu.d dVar) {
            this.ˏ = dVar.ॱᐨ;
            this.ˏ.ˋ(12);
        }

        public int ॱ() {
            return this.ˎ;
        }

        public int ˋ() {
            return this.ॱ == 0 ? this.ˏ.ʽॱ() : this.ॱ;
        }

        public boolean ˏ() {
            return this.ॱ != 0;
        }
    }

    static final class i {
        private final int ˊ;
        private final int ˋ;
        private final long ˏ;

        public i(int i, long j, int i2) {
            this.ˊ = i;
            this.ˏ = j;
            this.ˋ = i2;
        }
    }

    public static Track ॱ(o.aeu.e eVar, o.aeu.d dVar, long j, DrmInitData drmInitData, boolean z, boolean z2) throws ParserException {
        o.aeu.e ˋ = eVar.ˋ(aeu.ˋˋ);
        int ˋ2 = ˋ(ˋ(ˋ.ˊ(aeu.ـ).ॱᐨ));
        if (ˋ2 == -1) {
            return null;
        }
        long ॱ;
        long j2;
        i ˎ = ˎ(eVar.ˊ(aeu.ॱʼ).ॱᐨ);
        if (j == -9223372036854775807L) {
            ॱ = ˎ.ˏ;
        } else {
            ॱ = j;
        }
        long ˊ = ˊ(dVar.ॱᐨ);
        if (ॱ == -9223372036854775807L) {
            j2 = -9223372036854775807L;
        } else {
            j2 = anr.ॱ(ॱ, 1000000, ˊ);
        }
        o.aeu.e ˋ3 = ˋ.ˋ(aeu.ˋᐝ).ˋ(aeu.ˌ);
        Pair ॱ2 = ॱ(ˋ.ˊ(aeu.ॱʻ).ॱᐨ);
        b ˎ2 = ˎ(ˋ3.ˊ(aeu.ᐨ).ॱᐨ, ˎ.ˊ, ˎ.ˋ, (String) ॱ2.second, drmInitData, z2);
        long[] jArr = null;
        long[] jArr2 = null;
        if (!z) {
            Pair ˏ = ˏ(eVar.ˋ(aeu.ॱʽ));
            jArr2 = (long[]) ˏ.second;
            jArr = (long[]) ˏ.first;
        }
        if (ˎ2.ˊ == null) {
            return null;
        }
        return new Track(ˎ.ˊ, ˋ2, ((Long) ॱ2.first).longValue(), ˊ, j2, ˎ2.ˊ, ˎ2.ˎ, ˎ2.ˋ, ˎ2.ˏ, jArr, jArr2);
    }

    public static afi ˎ(Track track, o.aeu.e eVar, aec o_aec) throws ParserException {
        d eVar2;
        o.aeu.d ˊ = eVar.ˊ(aeu.ʽᐝ);
        if (ˊ != null) {
            eVar2 = new e(ˊ);
        } else {
            ˊ = eVar.ˊ(aeu.ʽˋ);
            if (ˊ == null) {
                throw new ParserException("Track has no sample table size information");
            }
            eVar2 = new a(ˊ);
        }
        int ॱ = eVar2.ॱ();
        if (ॱ == 0) {
            return new afi(track, new long[0], new int[0], 0, new long[0], new int[0], -9223372036854775807L);
        }
        int ʽॱ;
        int i;
        int i2;
        Object obj;
        Object obj2;
        int i3;
        int i4;
        int i5;
        long j;
        Object obj3;
        Object obj4;
        long[] jArr;
        boolean z = false;
        ˊ = eVar.ˊ(aeu.ˊʼ);
        if (ˊ == null) {
            z = true;
            ˊ = eVar.ˊ(aeu.ˊʻ);
        }
        anc o_anc = ˊ.ॱᐨ;
        anc o_anc2 = eVar.ˊ(aeu.ʼᐝ).ॱᐨ;
        anc o_anc3 = eVar.ˊ(aeu.ʼˋ).ॱᐨ;
        ˊ = eVar.ˊ(aeu.ʽˊ);
        anc o_anc4 = ˊ != null ? ˊ.ॱᐨ : null;
        o.aeu.d ˊ2 = eVar.ˊ(aeu.ʾॱ);
        anc o_anc5 = ˊ2 != null ? ˊ2.ॱᐨ : null;
        c cVar = new c(o_anc2, o_anc, z);
        o_anc3.ˋ(12);
        int ʽॱ2 = o_anc3.ʽॱ() - 1;
        int ʽॱ3 = o_anc3.ʽॱ();
        int ʽॱ4 = o_anc3.ʽॱ();
        int i6 = 0;
        if (o_anc5 != null) {
            o_anc5.ˋ(12);
            i6 = o_anc5.ʽॱ();
        }
        if (o_anc4 != null) {
            o_anc4.ˋ(12);
            ʽॱ = o_anc4.ʽॱ();
            if (ʽॱ > 0) {
                i = ʽॱ;
                ʽॱ = o_anc4.ʽॱ() - 1;
                o_anc = o_anc4;
                i2 = i;
            } else {
                i = ʽॱ;
                ʽॱ = -1;
                o_anc = null;
                i2 = i;
            }
        } else {
            ʽॱ = -1;
            o_anc = o_anc4;
            i2 = 0;
        }
        if (eVar2.ˏ() && "audio/raw".equals(track.ॱॱ.ʽ) && ʽॱ2 == 0 && i6 == 0 && i2 == 0) {
            obj = 1;
        } else {
            obj = null;
        }
        int i7 = 0;
        Object copyOf;
        Object obj5;
        if (obj == null) {
            int i8;
            long[] jArr2;
            Object obj6;
            obj2 = new long[ॱ];
            Object obj7 = new int[ॱ];
            long[] jArr3 = new long[ॱ];
            Object obj8 = new int[ॱ];
            long j2 = 0;
            int i9 = 0;
            i3 = 0;
            int i10 = ʽॱ4;
            i4 = ʽॱ2;
            ʽॱ4 = ʽॱ;
            long j3 = 0;
            ʽॱ = i6;
            int i11 = i2;
            i2 = 0;
            int i12 = 0;
            while (i3 < ॱ) {
                i6 = i9;
                boolean z2 = true;
                while (i6 == 0) {
                    z2 = cVar.ˏ();
                    if (!z2) {
                        break;
                    }
                    j2 = cVar.ˏ;
                    i6 = cVar.ॱ;
                }
                if (!z2) {
                    amz.ˏ("AtomParsers", "Unexpected end of chunk data");
                    copyOf = Arrays.copyOf(obj2, i3);
                    obj = Arrays.copyOf(obj7, i3);
                    long[] copyOf2 = Arrays.copyOf(jArr3, i3);
                    Object copyOf3 = Arrays.copyOf(obj8, i3);
                    i5 = i3;
                    Object obj9 = copyOf3;
                    i8 = i6;
                    obj5 = copyOf;
                    copyOf = obj;
                    jArr2 = copyOf2;
                    obj6 = obj9;
                    break;
                }
                if (o_anc5 != null) {
                    while (i12 == 0 && ʽॱ > 0) {
                        i12 = o_anc5.ʽॱ();
                        i2 = o_anc5.ॱᐝ();
                        ʽॱ--;
                    }
                    i12--;
                }
                obj2[i3] = j2;
                obj7[i3] = eVar2.ˋ();
                if (obj7[i3] > i7) {
                    i7 = obj7[i3];
                }
                jArr3[i3] = ((long) i2) + j3;
                obj8[i3] = o_anc == null ? 1 : 0;
                if (i3 == ʽॱ4) {
                    obj8[i3] = 1;
                    i9 = i11 - 1;
                    if (i9 > 0) {
                        ʽॱ4 = o_anc.ʽॱ() - 1;
                        i11 = i9;
                    } else {
                        i11 = i9;
                    }
                }
                j3 += (long) i10;
                i9 = ʽॱ3 - 1;
                if (i9 != 0 || i4 <= 0) {
                    i = i10;
                    i10 = i9;
                    i9 = i;
                } else {
                    i10 = o_anc3.ʽॱ();
                    i9 = o_anc3.ॱᐝ();
                    i4--;
                }
                j2 += (long) obj7[i3];
                i3++;
                ʽॱ3 = i10;
                i10 = i9;
                i9 = i6 - 1;
            }
            i8 = i9;
            obj6 = obj8;
            copyOf = obj7;
            obj5 = obj2;
            jArr2 = jArr3;
            i5 = ॱ;
            long j4 = ((long) i2) + j3;
            Object obj10 = 1;
            while (ʽॱ > 0) {
                if (o_anc5.ʽॱ() != 0) {
                    obj10 = null;
                    break;
                }
                o_anc5.ॱᐝ();
                ʽॱ--;
            }
            if (!(i11 == 0 && ʽॱ3 == 0 && i8 == 0 && i4 == 0 && i12 == 0 && obj10 != null)) {
                String str;
                String str2 = "AtomParsers";
                StringBuilder append = new StringBuilder().append("Inconsistent stbl box for track ").append(track.ˊ).append(": remainingSynchronizationSamples ").append(i11).append(", remainingSamplesAtTimestampDelta ").append(ʽॱ3).append(", remainingSamplesInChunk ").append(i8).append(", remainingTimestampDeltaChanges ").append(i4).append(", remainingSamplesAtTimestampOffset ").append(i12);
                if (obj10 == null) {
                    str = ", ctts invalid";
                } else {
                    str = "";
                }
                amz.ˏ(str2, append.append(str).toString());
            }
            j = j4;
            ॱ = i7;
            obj3 = copyOf;
            obj4 = obj5;
            ʽॱ3 = i5;
            jArr = jArr2;
            obj = obj6;
        } else {
            long[] jArr4 = new long[cVar.ˊ];
            int[] iArr = new int[cVar.ˊ];
            while (cVar.ˏ()) {
                jArr4[cVar.ˎ] = cVar.ˏ;
                iArr[cVar.ˎ] = cVar.ॱ;
            }
            o.aey.e ˊ3 = aey.ˊ(anr.ˊ(track.ॱॱ.ʿ, track.ॱॱ.ॱˎ), jArr4, iArr, (long) ʽॱ4);
            obj5 = ˊ3.ˎ;
            copyOf = ˊ3.ˊ;
            ʽॱ = ˊ3.ˏ;
            jArr = ˊ3.ˋ;
            obj = ˊ3.ॱ;
            j = ˊ3.ᐝ;
            obj3 = copyOf;
            obj4 = obj5;
            ʽॱ3 = ॱ;
            ॱ = ʽॱ;
        }
        long ॱ2 = anr.ॱ(j, 1000000, track.ॱ);
        if (track.ᐝ == null || o_aec.ˎ()) {
            anr.ˊ(jArr, 1000000, track.ॱ);
            return new afi(track, obj4, obj3, ॱ, jArr, obj, ॱ2);
        }
        long j5;
        long ॱ3;
        long j6;
        if (track.ᐝ.length == 1 && track.ˋ == 1 && jArr.length >= 2) {
            j5 = track.ʽ[0];
            ॱ3 = j5 + anr.ॱ(track.ᐝ[0], track.ॱ, track.ˏ);
            if (ˋ(jArr, j, j5, ॱ3)) {
                j6 = j - ॱ3;
                j5 = anr.ॱ(j5 - jArr[0], (long) track.ॱॱ.ʼॱ, track.ॱ);
                j6 = anr.ॱ(j6, (long) track.ॱॱ.ʼॱ, track.ॱ);
                if (!(j5 == 0 && j6 == 0) && j5 <= 2147483647L && j6 <= 2147483647L) {
                    o_aec.ˏ = (int) j5;
                    o_aec.ॱ = (int) j6;
                    anr.ˊ(jArr, 1000000, track.ॱ);
                    return new afi(track, obj4, obj3, ॱ, jArr, obj, anr.ॱ(track.ᐝ[0], 1000000, track.ˏ));
                }
            }
        }
        if (track.ᐝ.length == 1 && track.ᐝ[0] == 0) {
            j6 = track.ʽ[0];
            for (ʽॱ = 0; ʽॱ < jArr.length; ʽॱ++) {
                jArr[ʽॱ] = anr.ॱ(jArr[ʽॱ] - j6, 1000000, track.ॱ);
            }
            return new afi(track, obj4, obj3, ॱ, jArr, obj, anr.ॱ(j - j6, 1000000, track.ॱ));
        }
        boolean z3;
        int i13;
        Object obj11;
        Object obj12;
        int i14;
        if (track.ˋ == 1) {
            z3 = true;
        } else {
            z3 = false;
        }
        int[] iArr2 = new int[track.ᐝ.length];
        int[] iArr3 = new int[track.ᐝ.length];
        i4 = 0;
        i6 = 0;
        i5 = 0;
        int i15 = 0;
        while (i4 < track.ᐝ.length) {
            ॱ3 = track.ʽ[i4];
            if (ॱ3 != -1) {
                j = anr.ॱ(track.ᐝ[i4], track.ॱ, track.ˏ);
                iArr2[i4] = anr.ॱ(jArr, ॱ3, true, true);
                iArr3[i4] = anr.ॱ(jArr, j + ॱ3, z3, false);
                while (iArr2[i4] < iArr3[i4] && (obj[iArr2[i4]] & 1) == 0) {
                    iArr2[i4] = iArr2[i4] + 1;
                }
                i13 = i15 + (iArr3[i4] - iArr2[i4]);
                i2 = i6 | (i5 != iArr2[i4] ? 1 : 0);
                ʽॱ = iArr3[i4];
            } else {
                i2 = i6;
                ʽॱ = i5;
                i13 = i15;
            }
            i4++;
            i6 = i2;
            i5 = ʽॱ;
            i15 = i13;
        }
        int i16 = i6 | (i15 != ʽॱ3 ? 1 : 0);
        if (i16 != 0) {
            obj11 = new long[i15];
        } else {
            obj11 = obj4;
        }
        if (i16 != 0) {
            obj12 = new int[i15];
        } else {
            obj12 = obj3;
        }
        if (i16 != 0) {
            i14 = 0;
        } else {
            i14 = ॱ;
        }
        if (i16 != 0) {
            obj2 = new int[i15];
        } else {
            obj2 = obj;
        }
        long[] jArr5 = new long[i15];
        i3 = 0;
        i6 = i14;
        ʽॱ = 0;
        j = 0;
        while (i3 < track.ᐝ.length) {
            long j7 = track.ʽ[i3];
            i13 = iArr2[i3];
            int i17 = iArr3[i3];
            if (i16 != 0) {
                i14 = i17 - i13;
                System.arraycopy(obj4, i13, obj11, ʽॱ, i14);
                System.arraycopy(obj3, i13, obj12, ʽॱ, i14);
                System.arraycopy(obj, i13, obj2, ʽॱ, i14);
            }
            ॱ = ʽॱ;
            ʽॱ3 = i6;
            for (int i18 = i13; i18 < i17; i18++) {
                jArr5[ॱ] = anr.ॱ(j, 1000000, track.ˏ) + anr.ॱ(jArr[i18] - j7, 1000000, track.ॱ);
                if (i16 != 0 && obj12[ॱ] > ʽॱ3) {
                    ʽॱ3 = obj3[i18];
                }
                ॱ++;
            }
            j5 = track.ᐝ[i3] + j;
            i3++;
            i6 = ʽॱ3;
            j = j5;
            ʽॱ = ॱ;
        }
        return new afi(track, obj11, obj12, i6, jArr5, obj2, anr.ॱ(j, 1000000, track.ˏ));
    }

    @Nullable
    public static Metadata ˏ(o.aeu.d dVar, boolean z) {
        if (z) {
            return null;
        }
        anc o_anc = dVar.ॱᐨ;
        o_anc.ˋ(8);
        while (o_anc.ˊ() >= 8) {
            int ˋ = o_anc.ˋ();
            int ॱᐝ = o_anc.ॱᐝ();
            if (o_anc.ॱᐝ() == aeu.ˋʻ) {
                o_anc.ˋ(ˋ);
                return ˊ(o_anc, ˋ + ॱᐝ);
            }
            o_anc.ˋ(ˋ + ॱᐝ);
        }
        return null;
    }

    @Nullable
    public static Metadata ˊ(o.aeu.e eVar) {
        o.aeu.d ˊ = eVar.ˊ(aeu.ـ);
        o.aeu.d ˊ2 = eVar.ˊ(aeu.ˎͺ);
        o.aeu.d ˊ3 = eVar.ˊ(aeu.ˑॱ);
        if (ˊ == null || ˊ2 == null || ˊ3 == null || ˋ(ˊ.ॱᐨ) != ʽ) {
            return null;
        }
        anc o_anc = ˊ2.ॱᐨ;
        o_anc.ˋ(12);
        int ॱᐝ = o_anc.ॱᐝ();
        String[] strArr = new String[ॱᐝ];
        for (int i = 0; i < ॱᐝ; i++) {
            int ॱᐝ2 = o_anc.ॱᐝ();
            o_anc.ˎ(4);
            strArr[i] = o_anc.ˊ(ॱᐝ2 - 8);
        }
        anc o_anc2 = ˊ3.ॱᐨ;
        o_anc2.ˋ(8);
        List arrayList = new ArrayList();
        while (o_anc2.ˊ() > 8) {
            int ˋ = o_anc2.ˋ();
            ॱᐝ = o_anc2.ॱᐝ();
            ॱᐝ2 = o_anc2.ॱᐝ() - 1;
            if (ॱᐝ2 < 0 || ॱᐝ2 >= strArr.length) {
                amz.ˏ("AtomParsers", "Skipped metadata with unknown key index: " + ॱᐝ2);
            } else {
                MdtaMetadataEntry ॱ = afa.ॱ(o_anc2, ˋ + ॱᐝ, strArr[ॱᐝ2]);
                if (ॱ != null) {
                    arrayList.add(ॱ);
                }
            }
            o_anc2.ˋ(ˋ + ॱᐝ);
        }
        if (arrayList.isEmpty()) {
            return null;
        }
        return new Metadata(arrayList);
    }

    @Nullable
    private static Metadata ˊ(anc o_anc, int i) {
        o_anc.ˎ(12);
        while (o_anc.ˋ() < i) {
            int ˋ = o_anc.ˋ();
            int ॱᐝ = o_anc.ॱᐝ();
            if (o_anc.ॱᐝ() == aeu.ˑॱ) {
                o_anc.ˋ(ˋ);
                return ˎ(o_anc, ˋ + ॱᐝ);
            }
            o_anc.ˋ(ˋ + ॱᐝ);
        }
        return null;
    }

    @Nullable
    private static Metadata ˎ(anc o_anc, int i) {
        o_anc.ˎ(8);
        List arrayList = new ArrayList();
        while (o_anc.ˋ() < i) {
            Entry ˊ = afa.ˊ(o_anc);
            if (ˊ != null) {
                arrayList.add(ˊ);
            }
        }
        return arrayList.isEmpty() ? null : new Metadata(arrayList);
    }

    private static long ˊ(anc o_anc) {
        int i = 8;
        o_anc.ˋ(8);
        if (aeu.ॱ(o_anc.ॱᐝ()) != 0) {
            i = 16;
        }
        o_anc.ˎ(i);
        return o_anc.ˋॱ();
    }

    private static i ˎ(anc o_anc) {
        long j;
        int i = 8;
        o_anc.ˋ(8);
        int ॱ = aeu.ॱ(o_anc.ॱᐝ());
        o_anc.ˎ(ॱ == 0 ? 8 : 16);
        int ॱᐝ = o_anc.ॱᐝ();
        o_anc.ˎ(4);
        Object obj = 1;
        int ˋ = o_anc.ˋ();
        if (ॱ == 0) {
            i = 4;
        }
        for (int i2 = 0; i2 < i; i2++) {
            if (o_anc.ˏ[ˋ + i2] != (byte) -1) {
                obj = null;
                break;
            }
        }
        if (obj != null) {
            o_anc.ˎ(i);
            j = -9223372036854775807L;
        } else {
            j = ॱ == 0 ? o_anc.ˋॱ() : o_anc.ʼॱ();
            if (j == 0) {
                j = -9223372036854775807L;
            }
        }
        o_anc.ˎ(16);
        int ॱᐝ2 = o_anc.ॱᐝ();
        int ॱᐝ3 = o_anc.ॱᐝ();
        o_anc.ˎ(4);
        int ॱᐝ4 = o_anc.ॱᐝ();
        int ॱᐝ5 = o_anc.ॱᐝ();
        ॱᐝ2 = (ॱᐝ2 == 0 && ॱᐝ3 == WXMediaMessage.THUMB_LENGTH_LIMIT && ॱᐝ4 == (-65536) && ॱᐝ5 == 0) ? 90 : (ॱᐝ2 == 0 && ॱᐝ3 == (-65536) && ॱᐝ4 == WXMediaMessage.THUMB_LENGTH_LIMIT && ॱᐝ5 == 0) ? 270 : (ॱᐝ2 == (-65536) && ॱᐝ3 == 0 && ॱᐝ4 == 0 && ॱᐝ5 == (-65536)) ? 180 : 0;
        return new i(ॱᐝ, j, ॱᐝ2);
    }

    private static int ˋ(anc o_anc) {
        o_anc.ˋ(16);
        return o_anc.ॱᐝ();
    }

    private static int ˋ(int i) {
        if (i == ˊ) {
            return 1;
        }
        if (i == ˎ) {
            return 2;
        }
        if (i == ˋ || i == ˏ || i == ॱ || i == ॱॱ) {
            return 3;
        }
        if (i == ʻ) {
            return 4;
        }
        return -1;
    }

    private static Pair<Long, String> ॱ(anc o_anc) {
        int i = 8;
        o_anc.ˋ(8);
        int ॱ = aeu.ॱ(o_anc.ॱᐝ());
        o_anc.ˎ(ॱ == 0 ? 8 : 16);
        long ˋॱ = o_anc.ˋॱ();
        if (ॱ == 0) {
            i = 4;
        }
        o_anc.ˎ(i);
        int ॱॱ = o_anc.ॱॱ();
        return Pair.create(Long.valueOf(ˋॱ), "" + ((char) (((ॱॱ >> 10) & 31) + 96)) + ((char) (((ॱॱ >> 5) & 31) + 96)) + ((char) ((ॱॱ & 31) + 96)));
    }

    private static b ˎ(anc o_anc, int i, int i2, String str, DrmInitData drmInitData, boolean z) throws ParserException {
        o_anc.ˋ(12);
        int ॱᐝ = o_anc.ॱᐝ();
        b bVar = new b(ॱᐝ);
        for (int i3 = 0; i3 < ॱᐝ; i3++) {
            int ˋ = o_anc.ˋ();
            int ॱᐝ2 = o_anc.ॱᐝ();
            amm.ˊ(ॱᐝ2 > 0, "childAtomSize should be positive");
            int ॱᐝ3 = o_anc.ॱᐝ();
            if (ॱᐝ3 == aeu.ˋ || ॱᐝ3 == aeu.ॱ || ॱᐝ3 == aeu.ꜞ || ॱᐝ3 == aeu.ʻˋ || ॱᐝ3 == aeu.ˎ || ॱᐝ3 == aeu.ˏ || ॱᐝ3 == aeu.ʼ || ॱᐝ3 == aeu.ـॱ || ॱᐝ3 == aeu.ॱʾ) {
                ˎ(o_anc, ॱᐝ3, ˋ, ॱᐝ2, i, i2, drmInitData, bVar, i3);
            } else if (ॱᐝ3 == aeu.ʻ || ॱᐝ3 == aeu.ㆍ || ॱᐝ3 == aeu.ͺ || ॱᐝ3 == aeu.ॱˎ || ॱᐝ3 == aeu.ॱᐝ || ॱᐝ3 == aeu.ʽॱ || ॱᐝ3 == aeu.ʻॱ || ॱᐝ3 == aeu.ᐝॱ || ॱᐝ3 == aeu.ˋʼ || ॱᐝ3 == aeu.ˋʽ || ॱᐝ3 == aeu.ॱˊ || ॱᐝ3 == aeu.ˋॱ || ॱᐝ3 == aeu.ʽ || ॱᐝ3 == aeu.ॱˈ || ॱᐝ3 == aeu.ߵ || ॱᐝ3 == aeu.ॱـ || ॱᐝ3 == aeu.ॱˍ || ॱᐝ3 == aeu.ॱˑ) {
                ˎ(o_anc, ॱᐝ3, ˋ, ॱᐝ2, i, str, z, drmInitData, bVar, i3);
            } else if (ॱᐝ3 == aeu.ʻˊ || ॱᐝ3 == aeu.ʿॱ || ॱᐝ3 == aeu.ˈॱ || ॱᐝ3 == aeu.ˉॱ || ॱᐝ3 == aeu.ˊʽ) {
                ॱ(o_anc, ॱᐝ3, ˋ, ॱᐝ2, i, str, bVar);
            } else if (ॱᐝ3 == aeu.ॱʿ) {
                bVar.ˊ = Format.ˏ(Integer.toString(i), "application/x-camera-motion", null, -1, null);
            }
            o_anc.ˋ(ˋ + ॱᐝ2);
        }
        return bVar;
    }

    private static void ॱ(anc o_anc, int i, int i2, int i3, int i4, String str, b bVar) throws ParserException {
        String str2;
        o_anc.ˋ((i2 + 8) + 8);
        List list = null;
        long j = Long.MAX_VALUE;
        if (i == aeu.ʻˊ) {
            str2 = "application/ttml+xml";
        } else if (i == aeu.ʿॱ) {
            str2 = "application/x-quicktime-tx3g";
            int i5 = (i3 - 8) - 8;
            Object obj = new byte[i5];
            o_anc.ˎ(obj, 0, i5);
            list = Collections.singletonList(obj);
        } else if (i == aeu.ˈॱ) {
            str2 = "application/x-mp4-vtt";
        } else if (i == aeu.ˉॱ) {
            str2 = "application/ttml+xml";
            j = 0;
        } else if (i == aeu.ˊʽ) {
            str2 = "application/x-mp4-cea-608";
            bVar.ˎ = 1;
        } else {
            throw new IllegalStateException();
        }
        bVar.ˊ = Format.ˏ(Integer.toString(i4), str2, null, -1, 0, str, -1, null, j, list);
    }

    private static void ˎ(anc o_anc, int i, int i2, int i3, int i4, int i5, DrmInitData drmInitData, b bVar, int i6) throws ParserException {
        DrmInitData drmInitData2;
        o_anc.ˋ((i2 + 8) + 8);
        o_anc.ˎ(16);
        int ॱॱ = o_anc.ॱॱ();
        int ॱॱ2 = o_anc.ॱॱ();
        float f = 1.0f;
        o_anc.ˎ(50);
        int ˋ = o_anc.ˋ();
        if (i == aeu.ꜞ) {
            DrmInitData drmInitData3;
            Pair ˊ = ˊ(o_anc, i2, i3);
            if (ˊ != null) {
                i = ((Integer) ˊ.first).intValue();
                if (drmInitData == null) {
                    drmInitData3 = null;
                } else {
                    drmInitData3 = drmInitData.ˊ(((afe) ˊ.second).ˎ);
                }
                bVar.ˋ[i6] = (afe) ˊ.second;
            } else {
                drmInitData3 = drmInitData;
            }
            o_anc.ˋ(ˋ);
            drmInitData2 = drmInitData3;
        } else {
            drmInitData2 = drmInitData;
        }
        List list = null;
        String str = null;
        byte[] bArr = null;
        int i7 = -1;
        int i8 = ˋ;
        Object obj = null;
        int i9 = i8;
        while (i9 - i2 < i3) {
            o_anc.ˋ(i9);
            int ˋ2 = o_anc.ˋ();
            int ॱᐝ = o_anc.ॱᐝ();
            if (ॱᐝ != 0 || o_anc.ˋ() - i2 != i3) {
                Object obj2;
                amm.ˊ(ॱᐝ > 0, "childAtomSize should be positive");
                int ॱᐝ2 = o_anc.ॱᐝ();
                if (ॱᐝ2 == aeu.ˎˎ) {
                    amm.ˏ(str == null);
                    str = "video/avc";
                    o_anc.ˋ(ˋ2 + 8);
                    anw ॱ = anw.ॱ(o_anc);
                    list = ॱ.ˋ;
                    bVar.ˏ = ॱ.ˎ;
                    if (obj == null) {
                        f = ॱ.ˊ;
                    }
                    obj2 = obj;
                } else if (ॱᐝ2 == aeu.ˍ) {
                    amm.ˏ(str == null);
                    str = "video/hevc";
                    o_anc.ˋ(ˋ2 + 8);
                    any ˊ2 = any.ˊ(o_anc);
                    list = ˊ2.ˏ;
                    bVar.ˏ = ˊ2.ॱ;
                    obj2 = obj;
                } else if (ॱᐝ2 == aeu.ߺ) {
                    amm.ˏ(str == null);
                    str = i == aeu.ـॱ ? "video/x-vnd.on2.vp8" : "video/x-vnd.on2.vp9";
                    obj2 = obj;
                } else if (ॱᐝ2 == aeu.ᐝ) {
                    amm.ˏ(str == null);
                    str = "video/3gpp";
                    obj2 = obj;
                } else if (ॱᐝ2 == aeu.ˏˏ) {
                    amm.ˏ(str == null);
                    Pair ˋ3 = ˋ(o_anc, ˋ2);
                    String str2 = (String) ˋ3.first;
                    list = Collections.singletonList(ˋ3.second);
                    str = str2;
                    obj2 = obj;
                } else if (ॱᐝ2 == aeu.ʼˊ) {
                    f = ˏ(o_anc, ˋ2);
                    obj2 = 1;
                } else if (ॱᐝ2 == aeu.י) {
                    bArr = ˏ(o_anc, ˋ2, ॱᐝ);
                    obj2 = obj;
                } else {
                    if (ॱᐝ2 == aeu.ՙ) {
                        ॱᐝ2 = o_anc.ʽ();
                        o_anc.ˎ(3);
                        if (ॱᐝ2 == 0) {
                            switch (o_anc.ʽ()) {
                                case 0:
                                    i7 = 0;
                                    obj2 = obj;
                                    continue;
                                case 1:
                                    i7 = 1;
                                    obj2 = obj;
                                    continue;
                                case 2:
                                    i7 = 2;
                                    obj2 = obj;
                                    continue;
                                case 3:
                                    i7 = 3;
                                    obj2 = obj;
                                    continue;
                            }
                        }
                    }
                    obj2 = obj;
                }
                i9 += ॱᐝ;
                obj = obj2;
            } else if (str == null) {
                bVar.ˊ = Format.ˊ(Integer.toString(i4), str, null, -1, -1, ॱॱ, ॱॱ2, SizeModifier.STABLE_STATE_SCALE, list, i5, f, bArr, i7, null, drmInitData2);
            }
        }
        if (str == null) {
            bVar.ˊ = Format.ˊ(Integer.toString(i4), str, null, -1, -1, ॱॱ, ॱॱ2, SizeModifier.STABLE_STATE_SCALE, list, i5, f, bArr, i7, null, drmInitData2);
        }
    }

    private static Pair<long[], long[]> ˏ(o.aeu.e eVar) {
        if (eVar != null) {
            o.aeu.d ˊ = eVar.ˊ(aeu.ॱͺ);
            if (ˊ != null) {
                anc o_anc = ˊ.ॱᐨ;
                o_anc.ˋ(8);
                int ॱ = aeu.ॱ(o_anc.ॱᐝ());
                int ʽॱ = o_anc.ʽॱ();
                Object obj = new long[ʽॱ];
                Object obj2 = new long[ʽॱ];
                for (int i = 0; i < ʽॱ; i++) {
                    obj[i] = ॱ == 1 ? o_anc.ʼॱ() : o_anc.ˋॱ();
                    obj2[i] = ॱ == 1 ? o_anc.ॱˎ() : (long) o_anc.ॱᐝ();
                    if (o_anc.ˊॱ() != (short) 1) {
                        throw new IllegalArgumentException("Unsupported media rate.");
                    }
                    o_anc.ˎ(2);
                }
                return Pair.create(obj, obj2);
            }
        }
        return Pair.create(null, null);
    }

    private static float ˏ(anc o_anc, int i) {
        o_anc.ˋ(i + 8);
        return ((float) o_anc.ʽॱ()) / ((float) o_anc.ʽॱ());
    }

    private static void ˎ(anc o_anc, int i, int i2, int i3, int i4, String str, boolean z, DrmInitData drmInitData, b bVar, int i5) throws ParserException {
        int i6;
        int ॱॱ;
        DrmInitData drmInitData2;
        o_anc.ˋ((i2 + 8) + 8);
        if (z) {
            int ॱॱ2 = o_anc.ॱॱ();
            o_anc.ˎ(6);
            i6 = ॱॱ2;
        } else {
            o_anc.ˎ(8);
            i6 = 0;
        }
        if (i6 == 0 || i6 == 1) {
            ॱॱ = o_anc.ॱॱ();
            o_anc.ˎ(6);
            ॱॱ2 = o_anc.ॱˋ();
            if (i6 == 1) {
                o_anc.ˎ(16);
                i6 = ॱॱ;
                ॱॱ = ॱॱ2;
            } else {
                i6 = ॱॱ;
                ॱॱ = ॱॱ2;
            }
        } else if (i6 == 2) {
            o_anc.ˎ(16);
            ॱॱ2 = (int) Math.round(o_anc.ˈ());
            ॱॱ = o_anc.ʽॱ();
            o_anc.ˎ(20);
            i6 = ॱॱ;
            ॱॱ = ॱॱ2;
        } else {
            return;
        }
        int ˋ = o_anc.ˋ();
        if (i == aeu.ㆍ) {
            DrmInitData drmInitData3;
            Pair ˊ = ˊ(o_anc, i2, i3);
            if (ˊ != null) {
                i = ((Integer) ˊ.first).intValue();
                if (drmInitData == null) {
                    drmInitData3 = null;
                } else {
                    drmInitData3 = drmInitData.ˊ(((afe) ˊ.second).ˎ);
                }
                bVar.ˋ[i5] = (afe) ˊ.second;
            } else {
                drmInitData3 = drmInitData;
            }
            o_anc.ˋ(ˋ);
            drmInitData2 = drmInitData3;
        } else {
            drmInitData2 = drmInitData;
        }
        String str2 = null;
        if (i == aeu.ͺ) {
            str2 = "audio/ac3";
        } else if (i == aeu.ॱˎ) {
            str2 = "audio/eac3";
        } else if (i == aeu.ॱᐝ) {
            str2 = "audio/vnd.dts";
        } else if (i == aeu.ʻॱ || i == aeu.ᐝॱ) {
            str2 = "audio/vnd.dts.hd";
        } else if (i == aeu.ʽॱ) {
            str2 = "audio/vnd.dts.hd;profile=lbr";
        } else if (i == aeu.ˋʼ) {
            str2 = "audio/3gpp";
        } else if (i == aeu.ˋʽ) {
            str2 = "audio/amr-wb";
        } else if (i == aeu.ॱˊ || i == aeu.ˋॱ) {
            str2 = "audio/raw";
        } else if (i == aeu.ʽ) {
            str2 = "audio/mpeg";
        } else if (i == aeu.ॱˈ) {
            str2 = "audio/alac";
        } else if (i == aeu.ߵ) {
            str2 = "audio/g711-alaw";
        } else if (i == aeu.ॱـ) {
            str2 = "audio/g711-mlaw";
        } else if (i == aeu.ॱˍ) {
            str2 = "audio/opus";
        } else if (i == aeu.ॱˑ) {
            str2 = "audio/flac";
        }
        Object obj = null;
        int i7 = ॱॱ;
        int i8 = i6;
        String str3 = str2;
        while (ˋ - i2 < i3) {
            o_anc.ˋ(ˋ);
            int ॱᐝ = o_anc.ॱᐝ();
            amm.ˊ(ॱᐝ > 0, "childAtomSize should be positive");
            ॱॱ2 = o_anc.ॱᐝ();
            if (ॱॱ2 == aeu.ˏˏ || (z && ॱॱ2 == aeu.ˏॱ)) {
                Object obj2;
                if (ॱॱ2 == aeu.ˏˏ) {
                    ॱॱ2 = ˋ;
                } else {
                    ॱॱ2 = ˎ(o_anc, ˋ, ॱᐝ);
                }
                if (ॱॱ2 != -1) {
                    Pair ˋ2 = ˋ(o_anc, ॱॱ2);
                    str3 = (String) ˋ2.first;
                    obj2 = (byte[]) ˋ2.second;
                    if ("audio/mp4a-latm".equals(str3)) {
                        Pair ˋ3 = amr.ˋ((byte[]) obj2);
                        i7 = ((Integer) ˋ3.first).intValue();
                        i8 = ((Integer) ˋ3.second).intValue();
                    }
                } else {
                    obj2 = obj;
                }
                obj = obj2;
            } else if (ॱॱ2 == aeu.ˊॱ) {
                o_anc.ˋ(ˋ + 8);
                bVar.ˊ = Ac3Util.ॱ(o_anc, Integer.toString(i4), str, drmInitData2);
            } else if (ॱॱ2 == aeu.ॱˋ) {
                o_anc.ˋ(ˋ + 8);
                bVar.ˊ = Ac3Util.ˊ(o_anc, Integer.toString(i4), str, drmInitData2);
            } else if (ॱॱ2 == aeu.ʿ) {
                bVar.ˊ = Format.ˎ(Integer.toString(i4), str3, null, -1, -1, i8, i7, null, drmInitData2, 0, str);
            } else if (ॱॱ2 == aeu.ॱˈ) {
                obj = new byte[ॱᐝ];
                o_anc.ˋ(ˋ);
                o_anc.ˎ(obj, 0, ॱᐝ);
            } else if (ॱॱ2 == aeu.ॱˌ) {
                ॱॱ2 = ॱᐝ - 8;
                obj = new byte[(ᐝ.length + ॱॱ2)];
                System.arraycopy(ᐝ, 0, obj, 0, ᐝ.length);
                o_anc.ˋ(ˋ + 8);
                o_anc.ˎ(obj, ᐝ.length, ॱॱ2);
            } else if (ॱᐝ == aeu.ॱˉ) {
                ॱॱ2 = ॱᐝ - 12;
                obj = new byte[ॱॱ2];
                o_anc.ˋ(ˋ + 12);
                o_anc.ˎ(obj, 0, ॱॱ2);
            }
            ˋ += ॱᐝ;
        }
        if (bVar.ˊ == null && str3 != null) {
            List list;
            int i9 = "audio/raw".equals(str3) ? 2 : -1;
            String num = Integer.toString(i4);
            if (obj == null) {
                list = null;
            } else {
                list = Collections.singletonList(obj);
            }
            bVar.ˊ = Format.ˋ(num, str3, null, -1, -1, i8, i7, i9, list, drmInitData2, 0, str);
        }
    }

    private static int ˎ(anc o_anc, int i, int i2) {
        int ˋ = o_anc.ˋ();
        while (ˋ - i < i2) {
            o_anc.ˋ(ˋ);
            int ॱᐝ = o_anc.ॱᐝ();
            amm.ˊ(ॱᐝ > 0, "childAtomSize should be positive");
            if (o_anc.ॱᐝ() == aeu.ˏˏ) {
                return ˋ;
            }
            ˋ += ॱᐝ;
        }
        return -1;
    }

    private static Pair<String, byte[]> ˋ(anc o_anc, int i) {
        o_anc.ˋ((i + 8) + 4);
        o_anc.ˎ(1);
        ˏ(o_anc);
        o_anc.ˎ(2);
        int ʽ = o_anc.ʽ();
        if ((ʽ & DnsConfig.MAX_CACHE_ENTRIES) != 0) {
            o_anc.ˎ(2);
        }
        if ((ʽ & 64) != 0) {
            o_anc.ˎ(o_anc.ॱॱ());
        }
        if ((ʽ & 32) != 0) {
            o_anc.ˎ(2);
        }
        o_anc.ˎ(1);
        ˏ(o_anc);
        String ॱ = anb.ॱ(o_anc.ʽ());
        if ("audio/mpeg".equals(ॱ) || "audio/vnd.dts".equals(ॱ) || "audio/vnd.dts.hd".equals(ॱ)) {
            return Pair.create(ॱ, null);
        }
        o_anc.ˎ(12);
        o_anc.ˎ(1);
        int ˏ = ˏ(o_anc);
        Object obj = new byte[ˏ];
        o_anc.ˎ(obj, 0, ˏ);
        return Pair.create(ॱ, obj);
    }

    private static Pair<Integer, afe> ˊ(anc o_anc, int i, int i2) {
        int ˋ = o_anc.ˋ();
        while (ˋ - i < i2) {
            o_anc.ˋ(ˋ);
            int ॱᐝ = o_anc.ॱᐝ();
            amm.ˊ(ॱᐝ > 0, "childAtomSize should be positive");
            if (o_anc.ॱᐝ() == aeu.ᐧ) {
                Pair<Integer, afe> ॱ = ॱ(o_anc, ˋ, ॱᐝ);
                if (ॱ != null) {
                    return ॱ;
                }
            }
            ˋ += ॱᐝ;
        }
        return null;
    }

    static Pair<Integer, afe> ॱ(anc o_anc, int i, int i2) {
        boolean z = true;
        int i3 = i + 8;
        Object obj = null;
        String str = null;
        int i4 = 0;
        int i5 = -1;
        while (i3 - i < i2) {
            o_anc.ˋ(i3);
            int ॱᐝ = o_anc.ॱᐝ();
            int ॱᐝ2 = o_anc.ॱᐝ();
            if (ॱᐝ2 == aeu.ꓸ) {
                obj = Integer.valueOf(o_anc.ॱᐝ());
            } else if (ॱᐝ2 == aeu.ᐝˋ) {
                o_anc.ˎ(4);
                str = o_anc.ˊ(4);
            } else if (ॱᐝ2 == aeu.ᐝˊ) {
                i4 = ॱᐝ;
                i5 = i3;
            }
            i3 += ॱᐝ;
        }
        if (!"cenc".equals(str) && !"cbc1".equals(str) && !"cens".equals(str) && !"cbcs".equals(str)) {
            return null;
        }
        boolean z2;
        amm.ˊ(obj != null, "frma atom is mandatory");
        if (i5 != -1) {
            z2 = true;
        } else {
            z2 = false;
        }
        amm.ˊ(z2, "schi atom is mandatory");
        afe ॱ = ॱ(o_anc, i5, i4, str);
        if (ॱ == null) {
            z = false;
        }
        amm.ˊ(z, "tenc atom is mandatory");
        return Pair.create(obj, ॱ);
    }

    private static afe ॱ(anc o_anc, int i, int i2, String str) {
        byte[] bArr = null;
        boolean z = true;
        int i3 = i + 8;
        while (i3 - i < i2) {
            o_anc.ˋ(i3);
            int ॱᐝ = o_anc.ॱᐝ();
            if (o_anc.ॱᐝ() == aeu.ꜟ) {
                int i4;
                int i5;
                i3 = aeu.ॱ(o_anc.ॱᐝ());
                o_anc.ˎ(1);
                if (i3 == 0) {
                    o_anc.ˎ(1);
                    i4 = 0;
                    i5 = 0;
                } else {
                    i3 = o_anc.ʽ();
                    i5 = (i3 & 240) >> 4;
                    i4 = i3 & 15;
                }
                if (o_anc.ʽ() != 1) {
                    z = false;
                }
                ॱᐝ = o_anc.ʽ();
                byte[] bArr2 = new byte[16];
                o_anc.ˎ(bArr2, 0, bArr2.length);
                if (z && ॱᐝ == 0) {
                    i3 = o_anc.ʽ();
                    bArr = new byte[i3];
                    o_anc.ˎ(bArr, 0, i3);
                }
                return new afe(z, str, ॱᐝ, bArr2, i5, i4, bArr);
            }
            i3 += ॱᐝ;
        }
        return null;
    }

    private static byte[] ˏ(anc o_anc, int i, int i2) {
        int i3 = i + 8;
        while (i3 - i < i2) {
            o_anc.ˋ(i3);
            int ॱᐝ = o_anc.ॱᐝ();
            if (o_anc.ॱᐝ() == aeu.ߴ) {
                return Arrays.copyOfRange(o_anc.ˏ, i3, ॱᐝ + i3);
            }
            i3 += ॱᐝ;
        }
        return null;
    }

    private static int ˏ(anc o_anc) {
        int ʽ = o_anc.ʽ();
        int i = ʽ & 127;
        while ((ʽ & DnsConfig.MAX_CACHE_ENTRIES) == DnsConfig.MAX_CACHE_ENTRIES) {
            ʽ = o_anc.ʽ();
            i = (i << 7) | (ʽ & 127);
        }
        return i;
    }

    private static boolean ˋ(long[] jArr, long j, long j2, long j3) {
        int length = jArr.length - 1;
        int ॱ = anr.ॱ(3, 0, length);
        length = anr.ॱ(jArr.length - 3, 0, length);
        if (jArr[0] > j2 || j2 >= jArr[ॱ] || jArr[length] >= j3 || j3 > j) {
            return false;
        }
        return true;
    }
}
